/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import core.Doctor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JTable;

/**
 *
 * @author Marcin
 */
public class PopUpListener extends MouseAdapter {
    private JCalendar cal;
    private Doctor doctor;
    private boolean term;
    public PopUpListener(JCalendar cal,Doctor d,boolean term) {
        this.cal = cal;
        this.doctor = d;
        this.term = term;
    }
    @Override
    public void mousePressed(MouseEvent e) {
        if (e.isPopupTrigger()) {
            doPop(e);
        }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        if (e.isPopupTrigger()) {
            doPop(e);
        }
    }
    
    private void doPop(MouseEvent e) {
        if(!term){
            PopUpMenu menu = new PopUpMenu(doctor,cal);
            menu.show(e.getComponent(), e.getX(), e.getY());
        }
        else
        {
            PopUpMenuTerms menu = new PopUpMenuTerms(doctor,cal);
            menu.show(e.getComponent(), e.getX(), e.getY());    
        }
    }
}
